package rank

import "sort"

type IRanker interface {
	GetRankerId() int64 //上榜者ID
	GetScore() int64    //上榜分数
	GetSubScore() int64 //上榜次级分数
	GetTime() int64     //上榜时间
}

func Sort[T IRanker](rankers []T) {
	sort.Slice(rankers, func(i, j int) bool {
		result := rankers[i].GetScore() - rankers[j].GetScore()
		if result != 0 {
			if result > 0 {
				return true
			} else {
				return false
			}
		}
		result = rankers[i].GetSubScore() - rankers[j].GetSubScore()
		if result != 0 {
			if result > 0 {
				return true
			} else {
				return false
			}
		}
		result = rankers[i].GetTime() - rankers[j].GetTime()
		if result != 0 {
			if result > 0 {
				return false
			} else {
				return true
			}
		}
		return rankers[i].GetRankerId() < rankers[j].GetRankerId()
	})
}
